import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @program: itcast_health
 * @description:Apache POI 读取、创建excel表格
 * @author: ren
 * @create: 2020-02-25 21:39
 **/
public class test1 {
    public static void main(String[] args) throws IOException {
//        //创建工资表
//        XSSFWorkbook workbook = new XSSFWorkbook("D:\\test.xlsx");
//        //获取工作表，既可以根据工作表的顺序获取，也可以根据工作表的名称获取
//        XSSFSheet sheet = workbook.getSheetAt(0);
//        //遍历工作表获得行对象
//        for (Row row : sheet) {
//            for (Cell cell : row) {
//                System.out.println(cell.getStringCellValue());
//            }
//        }

        Workbook workbook = new XSSFWorkbook();
        Sheet sheet = workbook.createSheet();
        Row row = sheet.createRow(0);
        row.createCell(0).setCellValue("姓名");
        row.createCell(1).setCellValue("年龄");
        row.createCell(2).setCellValue("性别");
        FileOutputStream out = new FileOutputStream("D:\\aa.xlsx");
        workbook.write(out);
    }
}
